﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.gskinner.motion.plugins {
    import com.gskinner.motion.*;
    import flash.geom.*;

    public class ColorTransformPlugin {

        public static var enabled:Boolean = true;
        protected static var installed:Boolean = false;
        protected static var tweenProperties:Array = ["redMultiplier", "greenMultiplier", "blueMultiplier", "alphaMultiplier", "redOffset", "greenOffset", "blueOffset", "alphaOffset", "tint"];

        public static function install():void{
            if (installed){
                return;
            };
            installed = true;
            GTween.installPlugin(ColorTransformPlugin, tweenProperties, true);
        }
        public static function init(_arg1:GTween, _arg2:String, _arg3:Number):Number{
            var _local4:ColorTransform;
            var _local5:uint;
            var _local6:uint;
            var _local7:uint;
            var _local8:uint;
            var _local9:uint;
            if (!((((enabled) && ((_arg1.pluginData.ColorTransformEnabled == null)))) || (_arg1.pluginData.ColorTransformEnabled))){
                return (_arg3);
            };
            if (_arg2 == "tint"){
                _local4 = _arg1.target.transform.colorTransform;
                _local5 = Math.min(1, (1 - _local4.redMultiplier));
                _local6 = Math.min(0xFF, (_local4.redOffset * _local5));
                _local7 = Math.min(0xFF, (_local4.greenOffset * _local5));
                _local8 = Math.min(0xFF, (_local4.blueOffset * _local5));
                _local9 = (((((_local5 * 0xFF) << 24) | (_local6 << 16)) | (_local7 << 8)) | _local8);
                return (_local9);
            };
            return (_arg1.target.transform.colorTransform[_arg2]);
        }
        public static function tween(_arg1:GTween, _arg2:String, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean):Number{
            var _local9:uint;
            var _local10:uint;
            var _local11:uint;
            var _local12:uint;
            var _local13:uint;
            var _local14:uint;
            var _local15:uint;
            var _local16:uint;
            var _local17:uint;
            var _local18:Number;
            if (!(((((_arg1.pluginData.ColorTransformEnabled == null)) && (enabled))) || (_arg1.pluginData.ColorTransformEnabled))){
                return (_arg3);
            };
            var _local8:ColorTransform = _arg1.target.transform.colorTransform;
            if (_arg2 == "tint"){
                _local9 = ((_arg4 >> 24) & 0xFF);
                _local10 = ((_arg4 >> 16) & 0xFF);
                _local11 = ((_arg4 >> 8) & 0xFF);
                _local12 = (_arg4 & 0xFF);
                _local13 = ((_arg4 + _arg5) >> 0);
                _local14 = (_local9 + (_arg6 * (((_local13 >> 24) & 0xFF) - _local9)));
                _local15 = (_local10 + (_arg6 * (((_local13 >> 16) & 0xFF) - _local10)));
                _local16 = (_local11 + (_arg6 * (((_local13 >> 8) & 0xFF) - _local11)));
                _local17 = (_local12 + (_arg6 * ((_local13 & 0xFF) - _local12)));
                _local18 = (1 - (_local14 / 0xFF));
                _arg1.target.transform.colorTransform = new ColorTransform(_local18, _local18, _local18, _local8.alphaMultiplier, _local15, _local16, _local17, _local8.alphaOffset);
            } else {
                _local8[_arg2] = _arg3;
                _arg1.target.transform.colorTransform = _local8;
            };
            return (NaN);
        }

    }
}//package com.gskinner.motion.plugins 
